import random

x = random.randint(0, 9)
N = 0
while True:
    try:
        y = int(input("请输入猜想数字："))
        N = N + 1
        if y > x:
            print("遗憾，太大了")
        elif y < x:
            print("遗憾，太小了")
        elif y == x:
            print("预测{}次，你猜中了！".format(N))
            break
    except Exception:
        print("输入内容必须为整数！")
